package com.ruoyi.web.controller.gcgl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ConvertUpMoneyUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DecimalCalculateUtil;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.uuid.ReturnUUID;
import com.ruoyi.gcgl.domain.GcFk;
import com.ruoyi.gcgl.domain.GcFkfp;
import com.ruoyi.gcgl.domain.GcFkitem;
import com.ruoyi.gcgl.domain.GcProjectFlow;
import com.ruoyi.gcgl.domain.GcProjectOther;
import com.ruoyi.gcgl.domain.GcProjectQtfy;
import com.ruoyi.gcgl.domain.GcProjectSbclht;
import com.ruoyi.gcgl.domain.GcProjectSbclhtcrkd;
import com.ruoyi.gcgl.domain.GcProjectSbclhtcrkditem;
import com.ruoyi.gcgl.domain.GcProjectSbclhtjhd;
import com.ruoyi.gcgl.domain.GcProjectSgazht;
import com.ruoyi.gcgl.domain.GcProjectSgazhtjgys;
import com.ruoyi.gcgl.domain.GcProjectYbfy;
import com.ruoyi.gcgl.domain.GcSupply;
import com.ruoyi.gcgl.mapper.GcSendTipMapper;
import com.ruoyi.gcgl.service.IGcFkService;
import com.ruoyi.gcgl.service.IGcFkfpService;
import com.ruoyi.gcgl.service.IGcFkitemService;
import com.ruoyi.gcgl.service.IGcProjectFlowService;
import com.ruoyi.gcgl.service.IGcProjectOtherService;
import com.ruoyi.gcgl.service.IGcProjectQtfyService;
import com.ruoyi.gcgl.service.IGcProjectSbclhtService;
import com.ruoyi.gcgl.service.IGcProjectSbclhtcrkdService;
import com.ruoyi.gcgl.service.IGcProjectSbclhtcrkditemService;
import com.ruoyi.gcgl.service.IGcProjectSbclhtjhdService;
import com.ruoyi.gcgl.service.IGcProjectSgazhtService;
import com.ruoyi.gcgl.service.IGcProjectSgazhtjgysService;
import com.ruoyi.gcgl.service.IGcProjectYbfyService;
import com.ruoyi.gcgl.service.IGcSendTipService;
import com.ruoyi.gcgl.service.IGcSupplyService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.controller.tool.AliyunSmsUtils;

/**
 * 款项支付Controller
 * 
 * @author ruoyi
 * @date 2022-12-06
 */
@Controller
@RequestMapping("/gcgl/fk")
public class GcFkController extends BaseController
{
    private String prefix = "gcgl/fk";

    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private IGcFkService gcFkService;
    @Autowired
    private IGcFkitemService gcFkitemService;
    @Autowired
    private IGcProjectSbclhtService gcProjectSbclhtService;
    
    @Autowired
    private IGcProjectSbclhtjhdService gcProjectSbclhtjhdService;
    @Autowired
    private IGcProjectSbclhtcrkdService gcProjectSbclhtcrkdService;
    @Autowired
    private IGcProjectSbclhtcrkditemService gcProjectSbclhtcrkditemService;
    
    @Autowired
    private IGcProjectSgazhtService gcProjectSgazhtService;
    @Autowired
    private IGcProjectSgazhtjgysService gcProjectSgazhtjgysService;
    
    @Autowired
    private IGcSupplyService gcSupplyService;
    @Autowired
    private IGcProjectFlowService gcProjectFlowService;
    @Autowired
    private IGcProjectOtherService gcProjectOtherService;
    @Autowired
    private IGcProjectYbfyService gcProjectYbfyService;
    @Autowired
    private IGcProjectQtfyService gcProjectQtfyService;
    
    @Autowired
    private IGcFkfpService gcFkfpService;
    @Autowired
    private IGcSendTipService gcSendTipService;
    @Autowired
    private GcSendTipMapper gcSendTipMapper;
    
    @RequiresPermissions("gcgl:fk:view")
    @GetMapping()
    public String fk()
    {
        return prefix + "/fk";
    }

    /**
     * 查询款项支付列表
     */
    @RequiresPermissions("gcgl:fk:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GcFk gcFk)
    {
        startPage();
        gcFk.setDeleteFlag(1);
        if(getSysUser().isShow43R(getUserId())){
        gcFk.setCreateUser(getLoginName());
        }
        List<GcFk> list = gcFkService.selectGcFkList(gcFk);
        return getDataTable(list);
    }

    /**
     * 导出款项支付列表
     */
    @RequiresPermissions("gcgl:fk:export")
    @Log(title = "款项支付", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GcFk gcFk)
    {
    	gcFk.setDeleteFlag(1);
        if(getSysUser().isShow()){
        gcFk.setCreateUser(getLoginName());
        }
        List<GcFk> list = gcFkService.selectGcFkList(gcFk);
        ExcelUtil<GcFk> util = new ExcelUtil<GcFk>(GcFk.class);
        return util.exportExcel(list, "款项支付数据");
    }

    /**
     * 新增款项支付
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }
    
    /**
     * 新增设备材料合同出入库单
     */
    @GetMapping("/addsbcl/{sbclhtId}/{type}")
    public String addsbcl(@PathVariable("sbclhtId") Long sbclhtId, @PathVariable("type") Long type, ModelMap mmap){
    	GcProjectSbclht gcProjectSbclht = gcProjectSbclhtService.selectGcProjectSbclhtById(sbclhtId);
        mmap.put("obj", gcProjectSbclht);
        mmap.put("riq", DateUtils.dateTime(new Date()));
        mmap.put("type", type);
        mmap.put("xmfzr", gcProjectSbclht.getCreateUser());
        mmap.put("supplyName", gcProjectSbclht.getSupplyName());
        
        GcFk gcFk = new GcFk();
        gcFk.setDeleteFlag(1);
        gcFk.setProjectNo(gcProjectSbclht.getOrderNo());
        gcFk.setXmtype(Integer.parseInt(type.toString()));
        gcFk.setCkdw(gcProjectSbclht.getSupplyName());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk);
        
        double ljzf = 0.0;
        for(GcFk obj:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(obj.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcProjectSbclht.getId());
        gcFkfp.setGcProjectid(gcProjectSbclht.getGcProjectid());
        gcFkfp.setCkdw(gcProjectSbclht.getSupplyName());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        mmap.put("fkType", fplis.size()==0?"":fplis.get(0).getFpType());
        return prefix + "/add";
    }
    
    /**
     * 新增其他合同
     */
    @GetMapping("/addother/{otherId}/{type}")
    public String addother(@PathVariable("otherId") Long otherId, @PathVariable("type") Long type, ModelMap mmap){
    	GcProjectOther gcProjectOther = gcProjectOtherService.selectGcProjectOtherById(otherId);
        mmap.put("obj", gcProjectOther);
        mmap.put("riq", DateUtils.dateTime(new Date()));
        mmap.put("type", type);
        mmap.put("xmfzr", gcProjectOther.getCreateUser());
        mmap.put("orderNo", ReturnUUID.getOrderNo("ZF"));
        mmap.put("supplyName", gcProjectOther.getSupplyName());
        
        GcFk gcFk = new GcFk();
        gcFk.setDeleteFlag(1);
        gcFk.setProjectNo(gcProjectOther.getOrderNo());
        gcFk.setXmtype(Integer.parseInt(type.toString()));
        gcFk.setCkdw(gcProjectOther.getSupplyName());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk);
        
        double ljzf = 0.0;
        for(GcFk obj:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(obj.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcProjectOther.getId());
        gcFkfp.setGcProjectid(gcProjectOther.getGcProjectid());
        gcFkfp.setCkdw(gcProjectOther.getSupplyName());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        mmap.put("fkType", fplis.size()==0?"":fplis.get(0).getFpType());
        return prefix + "/add";
    }
    
    /**
     * 新增一般付款
     */
    @GetMapping("/addybfy/{ybfyId}/{type}")
    public String addybfy(@PathVariable("ybfyId") Long ybfyId, @PathVariable("type") Long type, ModelMap mmap){
    	GcProjectYbfy gcProjectYbfy = gcProjectYbfyService.selectGcProjectYbfyById(ybfyId);
        mmap.put("obj", gcProjectYbfy);
        mmap.put("riq", DateUtils.dateTime(new Date()));
        mmap.put("type", type);
        mmap.put("xmfzr", gcProjectYbfy.getCreateUser());
        mmap.put("orderNo", ReturnUUID.getOrderNo("ZF"));
        mmap.put("supplyName", gcProjectYbfy.getSupplyName());
        
        GcFk gcFk = new GcFk();
        gcFk.setDeleteFlag(1);
        gcFk.setProjectNo(gcProjectYbfy.getOrderNo());
        gcFk.setXmtype(Integer.parseInt(type.toString()));
        gcFk.setCkdw(gcProjectYbfy.getSupplyName());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk);
        
        double ljzf = 0.0;
        for(GcFk obj:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(obj.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcProjectYbfy.getId());
        gcFkfp.setGcProjectid(gcProjectYbfy.getGcProjectid());
        gcFkfp.setCkdw(gcProjectYbfy.getSupplyName());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        mmap.put("fkType", fplis.size()==0?"":fplis.get(0).getFpType());
        return prefix + "/add";
    }
    
    /**
     * 新增施工安装合同
     */
    @GetMapping("/addsgaz/{sgazhtId}/{type}")
    public String addsgaz(@PathVariable("sgazhtId") Long sgazhtId, @PathVariable("type") Long type, ModelMap mmap){
    	GcProjectSgazht gcProjectSgazht = gcProjectSgazhtService.selectGcProjectSgazhtById(sgazhtId);
        mmap.put("obj", gcProjectSgazht);
        mmap.put("riq", DateUtils.dateTime(new Date()));
        mmap.put("type", type);
        mmap.put("xmfzr", gcProjectSgazht.getCreateUser());
        mmap.put("orderNo", ReturnUUID.getOrderNo("ZF"));
        mmap.put("supplyName", gcProjectSgazht.getSupplyName());
        
        GcFk gcFk = new GcFk();
        gcFk.setDeleteFlag(1);
        gcFk.setProjectNo(gcProjectSgazht.getOrderNo());
        gcFk.setXmtype(Integer.parseInt(type.toString()));
        gcFk.setCkdw(gcProjectSgazht.getSupplyName());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk);
        
        double ljzf = 0.0;
        for(GcFk obj:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(obj.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcProjectSgazht.getId());
        gcFkfp.setGcProjectid(gcProjectSgazht.getGcProjectid());
        gcFkfp.setCkdw(gcProjectSgazht.getSupplyName());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        mmap.put("fkType", fplis.size()==0?"":fplis.get(0).getFpType());
        return prefix + "/add";
    }
    
    /**
     * 新增项目其它费用
     */
    @GetMapping("/addqtfy/{qtfyId}/{type}")
    public String addqtfy(@PathVariable("qtfyId") Long qtfyId, @PathVariable("type") Long type, ModelMap mmap){
    	GcProjectQtfy gcProjectQtfy = gcProjectQtfyService.selectGcProjectYbfyById(qtfyId);
        mmap.put("obj", gcProjectQtfy);
        mmap.put("riq", DateUtils.dateTime(new Date()));
        mmap.put("type", type);
        mmap.put("xmfzr", gcProjectQtfy.getCreateUser());
        mmap.put("orderNo", ReturnUUID.getOrderNo("ZF"));
        mmap.put("supplyName", gcProjectQtfy.getSupplyName());
        
        GcFk gcFk = new GcFk();
        gcFk.setDeleteFlag(1);
        gcFk.setProjectNo(gcProjectQtfy.getOrderNo());
        gcFk.setXmtype(Integer.parseInt(type.toString()));
//        gcFk.setCkdw(gcProjectQtfy.getSupplyName());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk);
        
        double ljzf = 0.0;
        for(GcFk obj:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(obj.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcProjectQtfy.getId());
        gcFkfp.setGcProjectid(gcProjectQtfy.getGcProjectid());
//        gcFkfp.setCkdw(gcProjectSgazht.getSupplyName());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        mmap.put("fkType", fplis.size()==0?"":fplis.get(0).getFpType());
        return prefix + "/add";
    }

    /**
     * 新增保存款项支付
     */
    @RequiresPermissions("gcgl:fk:add")
    @Log(title = "款项支付", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GcFk gcFk){
    	try {
    		SimpleDateFormat sdy = new SimpleDateFormat("yyyy");
    		SimpleDateFormat sdm = new SimpleDateFormat("MM");
    		int year = Integer.parseInt(sdy.format(new Date()));
    		int month = Integer.parseInt(sdm.format(new Date()));
    		GcFk newObj = new GcFk();
    		newObj.setDeleteFlag(1);
    		newObj.setCreateAt(DateUtils.getFisrtDayOfMonth(year, 1));
    		newObj.setUpdateAt(DateUtils.getLastDayOfMonth(year, 12));
    		List<GcFk> lisCount = gcFkService.selectGcFkList(newObj);
    		
    		String no = String.format("%04d", lisCount.size()+1);
    		gcFk.setOrderNo(year+"-"+no);
    		gcFk.setDeleteFlag(1);
        	gcFk.setStatus(0);
        	gcFk.setRiq(new Date());
        	gcFk.setCreateUser(getLoginName());
        	gcFk.setCreateAt(new Date());
        	gcFk.setUpdateUser(getLoginName());
        	gcFk.setUpdateAt(new Date());
        	
        	SysUser user = sysUserService.selectUserById(getUserId());
        	gcFk.setSqr(user.getZjsjName());//2024年12月30日修改，增加分管领导审批
        	
        	GcSupply gcSupply = new GcSupply();
        	gcSupply.setDeleteFlag(1);
        	gcSupply.setName(gcFk.getCkdw());
        	List<GcSupply> slis = gcSupplyService.selectGcSupplyList(gcSupply);
        	if(slis!=null && slis.size()>0){
        		gcFk.setNssbh(slis.get(0).getNssbh());
            	gcFk.setKhyh(slis.get(0).getKhyh());
            	gcFk.setSkzh(slis.get(0).getSkzh());
        	}
        	
        	gcFkService.insertGcFk(gcFk);
	        	
        	double ljzf = 0.0;
        	for(GcFkitem item : gcFk.getItems()){
        		
        		ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(item.getJine().toString()));
        		
        		item.setGcProjectid(gcFk.getGcProjectid());
        		item.setProjectId(gcFk.getProjectId());
        		item.setFkId(gcFk.getId());
        		item.setDeleteFlag(1);
        		item.setCreateUser(getLoginName());
        		item.setCreateAt(new Date());
        		item.setUpdateUser(getLoginName());
        		item.setUpdateAt(new Date());
        		gcFkitemService.insertGcFkitem(item);
        	}
        	
        	gcFk.setLjzf(Double.valueOf(ljzf));
        	gcFkService.updateGcFk(gcFk);
        	
        	//发送消息通知
//        	gcSendTipService.sendTipXm("fk", "款项支付", gcFk.getOrderNo(), 
//        			gcFk.getCreateUser(), DateUtils.dateTime(gcFk.getCreateAt()), 
//        			gcFk.getStatus().toString(), null, gcFk.getId().toString());
        	
        	try {
        		SysUser user1 = sysUserService.selectUserById(user.getZjsjId());
    			String phonenumber = user1.getPhonenumber();//分管领导
    			AliyunSmsUtils.returnSmsTz(phonenumber);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		} catch (Exception e) {
			return error(e.getMessage());
		}
    	
        return toAjax(1);
    }

    /**
     * 修改款项支付
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap){
        GcFk gcFk = gcFkService.selectGcFkById(id);
        if(gcFk.getFap()!=null && !gcFk.getFap().equals("")){
        gcFk.setFap(RuoYiConfig.getOnPath()+gcFk.getFap());
        }
        GcFkitem gcFkitem = new GcFkitem();
        gcFkitem.setFkId(id);
        List<GcFkitem> itemlis = gcFkitemService.selectGcFkitemList(gcFkitem);
        gcFk.setItems(itemlis);
        
        mmap.put("gcFk", gcFk);
        GcSupply gcSupply = new GcSupply();
        gcSupply.setDeleteFlag(1);
        List<GcSupply> supplylis = gcSupplyService.selectGcSupplyList(gcSupply);
        mmap.put("supplylis", supplylis);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcFk.getProjectId());
        gcFkfp.setGcProjectid(gcFk.getGcProjectid());
        gcFkfp.setCkdw(gcFk.getCkdw());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        
        GcFk gcFk11 = new GcFk();
        gcFk11.setDeleteFlag(1);
        gcFk11.setProjectNo(gcFk.getProjectNo());
        gcFk11.setXmtype(gcFk.getXmtype());
        gcFk11.setCkdw(gcFk.getCkdw());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk11);
        
        double ljzf = 0.0;
        for(GcFk obj:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(obj.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        return prefix + "/edit";
    }
    
    /**
     * 修改款项支付
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") Long id, ModelMap mmap){
        GcFk gcFk = gcFkService.selectGcFkById(id);
        if(gcFk.getFap()!=null && !gcFk.getFap().equals("")){
        gcFk.setFap(RuoYiConfig.getOnPath()+gcFk.getFap());
        }
        GcFkitem gcFkitem = new GcFkitem();
        gcFkitem.setFkId(id);
        List<GcFkitem> itemlis = gcFkitemService.selectGcFkitemList(gcFkitem);
        gcFk.setItems(itemlis);
        
        mmap.put("gcFk", gcFk);
        GcSupply gcSupply = new GcSupply();
        gcSupply.setDeleteFlag(1);
        List<GcSupply> supplylis = gcSupplyService.selectGcSupplyList(gcSupply);
        mmap.put("supplylis", supplylis);
        
        GcFkfp gcFkfp = new GcFkfp();
        gcFkfp.setDeleteFlag(1);
        gcFkfp.setProjectId(gcFk.getProjectId());
        gcFkfp.setGcProjectid(gcFk.getGcProjectid());
        gcFkfp.setCkdw(gcFk.getCkdw());
        List<GcFkfp> fplis = gcFkfpService.selectGcFkfpList(gcFkfp);
        double fpjine = 0.0;
        for(GcFkfp fp:fplis){
        	fpjine = DecimalCalculateUtil.add(fpjine, Double.parseDouble(fp.getFpjine().toString()));
        }
        mmap.put("fpjine", fpjine);
        
        //1.设备材料合同 2.施工安装合同 3.工程其它合同 4.一般性费用 5.其它费用
        if(gcFk.getXmtype()==1){
        	GcProjectSbclht gcProjectSbclht = new GcProjectSbclht();
        	gcProjectSbclht.setDeleteFlag(1);
        	gcProjectSbclht.setGcProjectid(gcFk.getGcProjectid());
        	List<GcProjectSbclht> sbclhtlis = 
        			gcProjectSbclhtService.selectGcProjectSbclhtList(gcProjectSbclht);
        	
        	for(GcProjectSbclht sbclht:sbclhtlis){
        		sbclht.setCreateUser("/gcgl/sbclht/detail/"+sbclht.getId());
        	}
        	
        	GcProjectSbclhtjhd gcProjectSbclhtjhd = new GcProjectSbclhtjhd();
        	gcProjectSbclhtjhd.setDeleteFlag(1);
        	gcProjectSbclhtjhd.setGcProjectid(gcFk.getGcProjectid());
        	List<GcProjectSbclhtjhd> sbclhtjhdlis = 
        			gcProjectSbclhtjhdService.selectGcProjectSbclhtjhdList(gcProjectSbclhtjhd);
        	
        	for(GcProjectSbclhtjhd obj:sbclhtjhdlis){
        		if(obj.getZilwj()!=null && !obj.getZilwj().equals("")){
				obj.setZilwj(RuoYiConfig.getOnPath()+obj.getZilwj());
        		}
			}
        	
        	GcProjectSbclhtcrkd gcProjectSbclhtcrkd = new GcProjectSbclhtcrkd();
        	gcProjectSbclhtcrkd.setDeleteFlag(1);
        	gcProjectSbclhtcrkd.setGcProjectid(gcFk.getGcProjectid());
        	List<GcProjectSbclhtcrkd> sbclhtcrkdlis = 
        			gcProjectSbclhtcrkdService.selectGcProjectSbclhtcrkdList(gcProjectSbclhtcrkd);
        	
        	for(GcProjectSbclhtcrkd obj : sbclhtcrkdlis){
        		GcProjectSbclhtcrkditem gcProjectSbclhtcrkditem = new GcProjectSbclhtcrkditem();
        		gcProjectSbclhtcrkditem.setDeleteFlag(1);
        		gcProjectSbclhtcrkditem.setGcProjectid(gcFk.getGcProjectid());
        		gcProjectSbclhtcrkditem.setSbclhtcrkdId(obj.getId());
        		List<GcProjectSbclhtcrkditem> items = gcProjectSbclhtcrkditemService.selectGcProjectSbclhtcrkditemList(gcProjectSbclhtcrkditem);
        		
        		obj.setCreateUser("/gcgl/sbclhtcrkd/rkprint/"+obj.getId());
        		obj.setItem(items);
        	}
        	
        	mmap.put("sbclhtlis", sbclhtlis);
        	mmap.put("sbclhtjhdlis", sbclhtjhdlis);
        	mmap.put("sbclhtcrkdlis", sbclhtcrkdlis);
		}else if(gcFk.getXmtype()==2){
			GcProjectSgazht gcProjectSgazht = new GcProjectSgazht();
			gcProjectSgazht.setDeleteFlag(1);
			gcProjectSgazht.setGcProjectid(gcFk.getGcProjectid());
			List<GcProjectSgazht> sgazhtlis = 
					gcProjectSgazhtService.selectGcProjectSgazhtList(gcProjectSgazht);
			
			for(GcProjectSgazht sgazht: sgazhtlis){
				sgazht.setCreateUser("/gcgl/sgazht/detail/"+sgazht.getId());
			}
			
			GcProjectSgazhtjgys gcProjectSgazhtjgys = new GcProjectSgazhtjgys();
			gcProjectSgazhtjgys.setDeleteFlag(1);
			gcProjectSgazhtjgys.setGcProjectid(gcFk.getGcProjectid());
			List<GcProjectSgazhtjgys> shazhtjgyslis = 
					gcProjectSgazhtjgysService.selectGcProjectSgazhtjgysList(gcProjectSgazhtjgys);
			
			for(GcProjectSgazhtjgys obj: shazhtjgyslis){
				if(obj.getZilwj()!=null && !obj.getZilwj().equals("")){
				obj.setZilwj(RuoYiConfig.getOnPath()+obj.getZilwj());
				}
			}
			
			mmap.put("sgazhtlis", sgazhtlis);
        	mmap.put("shazhtjgyslis", shazhtjgyslis);
		}else if(gcFk.getXmtype()==3){
			GcProjectOther gcProjectOther = new GcProjectOther();
			gcProjectOther.setDeleteFlag(1);
			gcProjectOther.setGcProjectid(gcFk.getGcProjectid());
			List<GcProjectOther> otherlis = 
					gcProjectOtherService.selectGcProjectOtherList(gcProjectOther);
			
			for(GcProjectOther obj:otherlis){
				if(obj.getZlwj()!=null && !obj.getZlwj().equals("")){
				obj.setZlwj(RuoYiConfig.getOnPath()+obj.getZlwj());
				}
			}
			
			mmap.put("otherlis", otherlis);
		}else if(gcFk.getXmtype()==4){
			GcProjectYbfy gcProjectYbfy = new GcProjectYbfy();
			gcProjectYbfy.setDeleteFlag(1);
			gcProjectYbfy.setGcProjectid(gcFk.getGcProjectid());
			List<GcProjectYbfy> ybfylis = 
					gcProjectYbfyService.selectGcProjectYbfyList(gcProjectYbfy);
			
			for(GcProjectYbfy obj:ybfylis){
				if(obj.getZlwj()!=null && !obj.getZlwj().equals("")){
				obj.setZlwj(RuoYiConfig.getOnPath()+obj.getZlwj());
				}
			}
			
			mmap.put("ybfylis", ybfylis);
		}else if(gcFk.getXmtype()==5){
			GcProjectQtfy gcProjectQtfy = new GcProjectQtfy();
			gcProjectQtfy.setDeleteFlag(1);
			gcProjectQtfy.setGcProjectid(gcFk.getGcProjectid());
			List<GcProjectQtfy> qtfylis = 
					gcProjectQtfyService.selectGcProjectYbfyList(gcProjectQtfy);
			
			for(GcProjectQtfy obj:qtfylis){
				if(obj.getZlwj()!=null && !obj.getZlwj().equals("")){
				obj.setZlwj(RuoYiConfig.getOnPath()+obj.getZlwj());
				}
			}
			
			mmap.put("qtfylis", qtfylis);
		}
        
        return prefix + "/detail";
    }

    /**
     * 修改保存款项支付
     */
    @Log(title = "款项支付", businessType = BusinessType.UPDATE)
    @PostMapping("/editSave")
    @ResponseBody
    public AjaxResult editSave(GcFk gcFk){
    	    	
    	try{
    		gcFkitemService.deleteGcFkitemById(gcFk.getId());
    		
    		double ljzf = 0.0;
    		for(GcFkitem item : gcFk.getItems()){
    			
    			ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(item.getJine().toString()));
    			
        		item.setGcProjectid(gcFk.getGcProjectid());
        		item.setProjectId(gcFk.getProjectId());
        		item.setFkId(gcFk.getId());
        		item.setDeleteFlag(1);
        		item.setCreateUser(getLoginName());
        		item.setCreateAt(new Date());
        		item.setUpdateUser(getLoginName());
        		item.setUpdateAt(new Date());
        		gcFkitemService.insertGcFkitem(item);
        	}
    		
    		gcFk.setLjzf(Double.valueOf(ljzf));
    		
            GcSupply gcSupply = new GcSupply();
        	gcSupply.setDeleteFlag(1);
        	gcSupply.setName(gcFk.getCkdw());
        	List<GcSupply> slis = gcSupplyService.selectGcSupplyList(gcSupply);
        	if(slis!=null && slis.size()>0){
        		gcFk.setNssbh(slis.get(0).getNssbh());
            	gcFk.setKhyh(slis.get(0).getKhyh());
            	gcFk.setSkzh(slis.get(0).getSkzh());
        	}
            
        	gcFk.setStatus(0);
        	gcFk.setZjlsb("");
        	gcFk.setCwsh("");
            gcFkService.updateGcFk(gcFk);
        }
        catch (Exception e){
            return error(e.getMessage());
        }
    	
        return toAjax(1);
    }

    /**
     * 删除款项支付
     */
    @RequiresPermissions("gcgl:fk:remove")
    @Log(title = "款项支付", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gcFkService.deleteGcFkByIds(ids));
    }
    
    //--------工程
    /**
     * 总经理审批
     * @return
     */
    @RequiresPermissions("gcgl:fk:gcpsview")
    @GetMapping("/gcps")
    public String fkgcps(){
        return prefix + "/fkgcps";
    }
    
    /**
     * 查询设备材料合同出入库单列表
     */
    @PostMapping("/gcpslist")
    @ResponseBody
    public TableDataInfo gcpslist(GcFk gcFk){
        startPage();
        gcFk.setDeleteFlag(1);
        gcFk.setStatus(0);
        List<GcFk> list = gcFkService.selectGcFkList(gcFk);
        return getDataTable(list);
    }
    
    @Log(title = "通过", businessType = BusinessType.UPDATE)
    @PostMapping("/gcyes")
    @ResponseBody
    public AjaxResult gcyes(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcFk gcFk = gcFkService.selectGcFkById(Long.valueOf(id[i].toString()));
    		if(gcFk!=null){
    			GcFk obj = new GcFk();
    			obj.setId(Long.parseLong(id[i]));
    			obj.setStatus(1);
    			obj.setSqr(getLoginName());
    			obj.setSqrAt(new Date());
    			obj.setSpyj(spyj);
    			gcFkService.updateGcFk(obj);
    			
    			GcFk l_obj = gcFkService.selectGcFkById(Long.parseLong(id[i]));
    			//发送消息通知
//            	gcSendTipService.sendTipXm("fk", "款项支付", l_obj.getOrderNo(), 
//            			l_obj.getCreateUser(), DateUtils.dateTime(l_obj.getCreateAt()), 
//            			l_obj.getStatus().toString(), null, l_obj.getId().toString());
    			
    			try {
//            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(gcFk.getCreateUser());
//            		if(userlis!=null && userlis.size()>0){
//            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
    				String phonenumber = caiw;
            			AliyunSmsUtils.returnSmsTz(phonenumber);
//            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	return toAjax(1);
    }
    
    @Log(title = "不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/gcno")
    @ResponseBody
    public AjaxResult gcno(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcFk gcFk = gcFkService.selectGcFkById(Long.valueOf(id[i].toString()));
    		if(gcFk!=null){
    			GcFk obj = new GcFk();
    			obj.setId(Long.parseLong(id[i]));
    			obj.setStatus(2);
    			obj.setSqr(getLoginName());
    			obj.setSqrAt(new Date());
    			obj.setSpyj(spyj);
    			gcFkService.updateGcFk(obj);
    			
    			GcFk l_obj = gcFkService.selectGcFkById(Long.parseLong(id[i]));
    			//发送消息通知
//            	gcSendTipService.sendTipXm("fk", "款项支付", l_obj.getOrderNo(), 
//            			l_obj.getCreateUser(), DateUtils.dateTime(l_obj.getCreateAt()), 
//            			l_obj.getStatus().toString(), null, l_obj.getId().toString());
    			
    			try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(l_obj.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	return toAjax(1);
    }
    
    /**
     * 总经理审批
     * @return
     */
    @RequiresPermissions("gcgl:fk:psview")
    @GetMapping("/ps")
    public String fkps(){
        return prefix + "/fkps";
    }
    
    /**
     * 查询设备材料合同出入库单列表
     */
    @PostMapping("/pslist")
    @ResponseBody
    public TableDataInfo pslist(GcFk gcFk){
        startPage();
        gcFk.setDeleteFlag(1);
        gcFk.setStatus(3);
        List<GcFk> list = gcFkService.selectGcFkList(gcFk);
        return getDataTable(list);
    }
    
    @Log(title = "通过", businessType = BusinessType.UPDATE)
    @PostMapping("/yes")
    @ResponseBody
    public AjaxResult yes(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcFk gcFk = gcFkService.selectGcFkById(Long.valueOf(id[i].toString()));
    		if(gcFk!=null){
    			GcFk obj = new GcFk();
    			obj.setId(Long.parseLong(id[i]));
    			obj.setStatus(5);
    			obj.setZjlsb(getLoginName());
    			obj.setZjlsbAt(new Date());
    			obj.setSpyj(spyj);
    			gcFkService.updateGcFk(obj);
    			
    			GcFk l_obj = gcFkService.selectGcFkById(Long.parseLong(id[i]));
    			//发送消息通知
//            	gcSendTipService.sendTipXm("fk", "款项支付", l_obj.getOrderNo(), 
//            			l_obj.getCreateUser(), DateUtils.dateTime(l_obj.getCreateAt()), 
//            			l_obj.getStatus().toString(), null, l_obj.getId().toString());
            	
            	try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(gcFk.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	return toAjax(1);
    }
    
    @Log(title = "不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/no")
    @ResponseBody
    public AjaxResult no(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcFk gcFk = gcFkService.selectGcFkById(Long.valueOf(id[i].toString()));
    		if(gcFk!=null){
    			GcFk obj = new GcFk();
    			obj.setId(Long.parseLong(id[i]));
    			obj.setStatus(6);
    			obj.setZjlsb(getLoginName());
    			obj.setZjlsbAt(new Date());
    			obj.setSpyj(spyj);
    			gcFkService.updateGcFk(obj);
    			
    			GcFk l_obj = gcFkService.selectGcFkById(Long.parseLong(id[i]));
    			//发送消息通知
//            	gcSendTipService.sendTipXm("fk", "款项支付", l_obj.getOrderNo(), 
//            			l_obj.getCreateUser(), DateUtils.dateTime(l_obj.getCreateAt()), 
//            			l_obj.getStatus().toString(), null, l_obj.getId().toString());
    			
    			try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(gcFk.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	return toAjax(1);
    }
    
    //会计审核
    @RequiresPermissions("gcgl:fk:hjpsview")
    @GetMapping("/fkhjps")
    public String fkhjps(){
        return prefix + "/fkhjps";
    }
    
    /**
     * 查询设备材料合同出入库单列表
     */
    @PostMapping("/hjpslist")
    @ResponseBody
    public TableDataInfo hjpslist(GcFk gcFk)
    {
    	startPage();
        gcFk.setDeleteFlag(1);
        String[] statuslis = new String[]{"1","3","5"};
        gcFk.setStatuslis(statuslis);
        List<GcFk> list = gcFkService.selectGcFkList(gcFk);
        return getDataTable(list);
    }
    
    @Log(title = "通过", businessType = BusinessType.UPDATE)
    @PostMapping("/hjpsyes")
    @ResponseBody
    public AjaxResult hjpsyes(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcFk gcFk = gcFkService.selectGcFkById(Long.valueOf(id[i].toString()));
    		if(gcFk!=null){
    			GcFk obj = new GcFk();
    			obj.setId(Long.parseLong(id[i]));
    			obj.setStatus(3);
    			obj.setCwsh(getLoginName());
    			obj.setCwshAt(new Date());
    			obj.setSpyj(spyj);
    			gcFkService.updateGcFk(obj);
    			
    			//设备材料合同付款设置为启动
    			GcProjectFlow gcProjectFlow = new GcProjectFlow();
    			gcProjectFlow.setGcProjectid(gcFk.getGcProjectid());
    			//项目
    			//1.设备材料合同 2.施工安装合同 3.工程其它合同 4.一般性费用
    			if(gcFk.getXmtype()==1){
    				gcProjectFlow.setSbclhtfk(1);
    			}else if(gcFk.getXmtype()==2){
    				gcProjectFlow.setShazhtfk(1);
    			}else if(gcFk.getXmtype()==3){
    				gcProjectFlow.setGcqthtfk(1);
    			}else if(gcFk.getXmtype()==4){
    				gcProjectFlow.setYbxfyfk(1);
    			}else if(gcFk.getXmtype()==5){
    				gcProjectFlow.setXmqtfy(1);;
    			}
    			
    			gcProjectFlowService.updateGcProjectFlow(gcProjectFlow);
    			
    			GcFk l_obj = gcFkService.selectGcFkById(Long.parseLong(id[i]));
    			//发送消息通知
//            	gcSendTipService.sendTipXm("fk", "款项支付", l_obj.getOrderNo(), 
//            			l_obj.getCreateUser(), DateUtils.dateTime(l_obj.getCreateAt()), 
//            			l_obj.getStatus().toString(), null, l_obj.getId().toString());
            	
            	try {
//            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(l_obj.getCreateUser());
//            		if(userlis!=null && userlis.size()>0){
//            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            		String phonenumber = zjl;
            			AliyunSmsUtils.returnSmsTz(phonenumber);
//            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	return toAjax(1);
    }
    
    @Log(title = "不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/hjpsno")
    @ResponseBody
    public AjaxResult hjpsno(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcFk gcFk = gcFkService.selectGcFkById(Long.valueOf(id[i].toString()));
    		if(gcFk!=null){
    			GcFk obj = new GcFk();
    			obj.setId(Long.parseLong(id[i]));
    			obj.setStatus(4);
    			obj.setCwsh(getLoginName());
    			obj.setCwshAt(new Date());
    			obj.setSpyj(spyj);
    			gcFkService.updateGcFk(obj);
    			
    			GcFk l_obj = gcFkService.selectGcFkById(Long.parseLong(id[i]));
    			//发送消息通知
//            	gcSendTipService.sendTipXm("fk", "款项支付", l_obj.getOrderNo(), 
//            			l_obj.getCreateUser(), DateUtils.dateTime(l_obj.getCreateAt()), 
//            			l_obj.getStatus().toString(), null, l_obj.getId().toString());
    			
    			try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(l_obj.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    	}
    	return toAjax(1);
    }
    
    @GetMapping("/fksqdprint/{id}")
    public String fksqdprint(@PathVariable("id") Long id, ModelMap mmap){
    	GcFk obj = gcFkService.selectGcFkById(id);
        
    	double ljzfLast =0.0;
    	GcFkitem items = new GcFkitem();
        items.setFkId(id);
        List<GcFkitem> itemlis= gcFkitemService.selectGcFkitemList(items);
        
        if(itemlis!=null && itemlis.size()<3){
        	
        	for(GcFkitem item:itemlis){
        		ljzfLast = DecimalCalculateUtil.add(ljzfLast, 
        				Double.parseDouble(item.getJine().toString()));
            }
        	
        	for(int i=itemlis.size();i<3;i++){
        		GcFkitem itemobj = new GcFkitem();
        		itemobj.setXuh(i);
            	itemlis.add(itemobj);
        	}
        	
        	obj.setItems(itemlis);
        }
//        double ljzf = DecimalCalculateUtil.add(ljzfLast, Double.parseDouble(obj.getLjzf().toString()));
//        obj.setLjzf(Double.valueOf(ljzfLast));
        
        GcFk gcFk11 = new GcFk();
        gcFk11.setDeleteFlag(1);
        gcFk11.setProjectNo(obj.getProjectNo());
        gcFk11.setXmtype(obj.getXmtype());
        gcFk11.setCkdw(obj.getCkdw());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk11);
        
        double ljzf = 0.0;
        for(GcFk gcFk22:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(gcFk22.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        Double h_zbs = DecimalCalculateUtil.div(ljzf, Double.parseDouble(obj.getHtzje().toString()), 4);
    	obj.setZbs(DecimalCalculateUtil.mul(h_zbs, 100)+"%");
        mmap.put("obj", obj);
        mmap.put("riq", DateUtils.dateTime(obj.getRiq()));
        mmap.put("ljzfdx", ConvertUpMoneyUtil.toChinese(obj.getLjzf().toString()));
        return prefix + "/fksqdprint";
    }
    
    @GetMapping("/fksqdgcsp/{id}")
    public String fksqdgcsp(@PathVariable("id") Long id, ModelMap mmap){
    	GcFk obj = gcFkService.selectGcFkById(id);
        
    	double ljzfLast =0.0;
    	GcFkitem items = new GcFkitem();
        items.setFkId(id);
        List<GcFkitem> itemlis= gcFkitemService.selectGcFkitemList(items);
        
        if(itemlis!=null && itemlis.size()<3){
        	
        	for(GcFkitem item:itemlis){
        		ljzfLast = DecimalCalculateUtil.add(ljzfLast, 
        				Double.parseDouble(item.getJine().toString()));
            }
        	
        	for(int i=itemlis.size();i<3;i++){
        		GcFkitem itemobj = new GcFkitem();
        		itemobj.setXuh(i);
            	itemlis.add(itemobj);
        	}
        	
        	obj.setItems(itemlis);
        }
        
        GcFk gcFk11 = new GcFk();
        gcFk11.setDeleteFlag(1);
        gcFk11.setProjectNo(obj.getProjectNo());
        gcFk11.setXmtype(obj.getXmtype());
        gcFk11.setCkdw(obj.getCkdw());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk11);
        
        double ljzf = 0.0;
        for(GcFk gcFk22:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(gcFk22.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        Double h_zbs = DecimalCalculateUtil.div(ljzf, Double.parseDouble(obj.getHtzje().toString()), 4);
    	obj.setZbs(DecimalCalculateUtil.mul(h_zbs, 100)+"%");
        mmap.put("obj", obj);
        mmap.put("riq", DateUtils.dateTime(obj.getRiq()));
        mmap.put("ljzfdx", ConvertUpMoneyUtil.toChinese(obj.getLjzf().toString()));
        return prefix + "/fksqdgcsp";
    }
    
    @GetMapping("/fksqdzjlsp/{id}")
    public String fksqdzjlsp(@PathVariable("id") Long id, ModelMap mmap){
    	GcFk obj = gcFkService.selectGcFkById(id);
        
    	double ljzfLast =0.0;
    	GcFkitem items = new GcFkitem();
        items.setFkId(id);
        List<GcFkitem> itemlis= gcFkitemService.selectGcFkitemList(items);
        
        if(itemlis!=null && itemlis.size()<3){
        	
        	for(GcFkitem item:itemlis){
        		ljzfLast = DecimalCalculateUtil.add(ljzfLast, 
        				Double.parseDouble(item.getJine().toString()));
            }
        	
        	for(int i=itemlis.size();i<3;i++){
        		GcFkitem itemobj = new GcFkitem();
        		itemobj.setXuh(i);
            	itemlis.add(itemobj);
        	}
        	
        	obj.setItems(itemlis);
        }
//        double ljzf = DecimalCalculateUtil.add(ljzfLast, Double.parseDouble(obj.getLjzf().toString()));
//        obj.setLjzf(Double.valueOf(ljzfLast));
        
        GcFk gcFk11 = new GcFk();
        gcFk11.setDeleteFlag(1);
        gcFk11.setProjectNo(obj.getProjectNo());
        gcFk11.setXmtype(obj.getXmtype());
        gcFk11.setCkdw(obj.getCkdw());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk11);
        
        double ljzf = 0.0;
        for(GcFk gcFk22:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(gcFk22.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        Double h_zbs = DecimalCalculateUtil.div(ljzf, Double.parseDouble(obj.getHtzje().toString()), 4);
    	obj.setZbs(DecimalCalculateUtil.mul(h_zbs, 100)+"%");
        mmap.put("obj", obj);
        mmap.put("riq", DateUtils.dateTime(obj.getRiq()));
        mmap.put("ljzfdx", ConvertUpMoneyUtil.toChinese(obj.getLjzf().toString()));
        return prefix + "/fksqdzjlsp";
    }
    
    @GetMapping("/fksqdhjsp/{id}")
    public String fksqdhjsp(@PathVariable("id") Long id, ModelMap mmap){
    	GcFk obj = gcFkService.selectGcFkById(id);
        
    	double ljzfLast =0.0;
    	GcFkitem items = new GcFkitem();
        items.setFkId(id);
        List<GcFkitem> itemlis= gcFkitemService.selectGcFkitemList(items);
        
        if(itemlis!=null && itemlis.size()<3){
        	
        	for(GcFkitem item:itemlis){
        		ljzfLast = DecimalCalculateUtil.add(ljzfLast, 
        				Double.parseDouble(item.getJine().toString()));
            }
        	
        	for(int i=itemlis.size();i<3;i++){
        		GcFkitem itemobj = new GcFkitem();
        		itemobj.setXuh(i);
            	itemlis.add(itemobj);
        	}
        	
        	obj.setItems(itemlis);
        }
//        double ljzf = DecimalCalculateUtil.add(ljzfLast, Double.parseDouble(obj.getLjzf().toString()));
//        obj.setLjzf(Double.valueOf(ljzfLast));
        
        GcFk gcFk11 = new GcFk();
        gcFk11.setDeleteFlag(1);
        gcFk11.setProjectNo(obj.getProjectNo());
        gcFk11.setXmtype(obj.getXmtype());
        gcFk11.setCkdw(obj.getCkdw());
        List<GcFk> gcfklis = gcFkService.selectGcFkList(gcFk11);
        
        double ljzf = 0.0;
        for(GcFk gcFk22:gcfklis){
        	ljzf = DecimalCalculateUtil.add(ljzf, Double.parseDouble(gcFk22.getLjzf().toString()));
        }
        mmap.put("kucljzf", ljzf);
        
        Double h_zbs = DecimalCalculateUtil.div(ljzf, Double.parseDouble(obj.getHtzje().toString()), 4);
    	obj.setZbs(DecimalCalculateUtil.mul(h_zbs, 100)+"%");
        mmap.put("obj", obj);
        mmap.put("riq", DateUtils.dateTime(obj.getRiq()));
        mmap.put("ljzfdx", ConvertUpMoneyUtil.toChinese(obj.getLjzf().toString()));
        return prefix + "/fksqdhjsp";
    }
}